import org.deep.cmd.CmdSource;

public class MockCmdSource extends CmdSource {
    private final HandleDataCallback handleDataCallback;

    public MockCmdSource(HandleDataCallback handleDataCallback) {
        this.handleDataCallback = handleDataCallback;
    }

    @Override
    public void write(byte[] buf) {
        if (handleDataCallback != null) {
            new Thread(() -> {
                byte[] result = handleDataCallback.handle(buf);
                queue.add(result);
                queueFromEvent.add(result);
            }).start();
        }
    }

    public interface HandleDataCallback {
        byte[] handle(byte[] buf);
    }
}
